﻿using System;

namespace NetCoreQuartzDemo
{
    /// <summary>
    ///计划任务设置
    /// </summary>
    [AttributeUsage(AttributeTargets.Class)]
    public class QuartzSetAttribute : Attribute
    {
        /// <summary>
        /// 计划任务名称
        /// </summary>
        public string JobName { get; set; }
        /// <summary>
        /// 计划间隔天
        /// </summary>
        public int Day { get; set; } = 0;
        /// <summary>
        /// 计划间隔小时
        /// </summary>
        public int Hour { get; set; } = 0;
        /// <summary>
        /// 计划间隔分钟
        /// </summary>
        public int Minutes { get; set; } = 0;
        /// <summary>
        /// 计划间隔秒
        /// </summary>
        public int Second { get; set; } = 10;
        /// <summary>
        /// 计划任务描述
        /// </summary>
        public string JobDescribe { get; set; }
        /// <summary>
        /// 计划任务 分组
        /// </summary>
        public string JobGroup { get; set; }

        /// <summary>
        /// 初始化计划任务【默认10秒】
        /// </summary>
        /// <param name="jobName">计划任务名称【必填】</param>
        /// <param name="jobGroup">计划任务分组【必填】</param>
        /// <param name="jobDescribe">计划任务描述</param>
        /// <param name="day">计划间隔天</param>
        /// <param name="hour">计划间隔小时</param>
        /// <param name="minutes">计划间隔分钟</param>
        /// <param name="second">计划间隔秒</param> 
        public QuartzSetAttribute(string jobName, string jobGroup, int day=0,int hour=0,int minutes=0,int second=10, string jobDescribe = default(string))
        {
            this.JobName = jobName;
            this.JobGroup = jobGroup;
            this.Day = day<0?0:day;
            this.Hour = hour < 0 ? 0 : hour; ;
            this.Minutes = minutes<0?0:minutes;
            this.Second = second <= 0 ? 10 : second;
            if (!string.IsNullOrEmpty(jobDescribe))
                this.JobDescribe = jobDescribe;
        }
    }
}